<template>

  <!--  //通过model初始化组件，    ref组件对象，获取组件中的暴露方法，实现黑盒模式的 显式互相调用。-->

  <SearchTablePage :search-config="baseTableSearchModel" :table-config="baseTableModel"/>

</template>

<script lang="tsx" setup>
import FrozenStatusTag from "/@/components/FrozenStatusTag.vue";

defineOptions({
  name: 'UserInfoAccountPageData',   //全局别名
  title: '表格页',   //标题
});
// 接口
import UserInfoAccountApi from '/@/api//UserInfoAccountApi.ts';


import FORM_FIELD_TYPE from '/@/constants/FormFieldType';
import VDialog from '/@/utils/dialogUtil.ts'
import FormFieldType from "/@/constants/FormFieldType";
import CommonFrozenStatusSelect from "/@/components/CommonFrozenStatusSelect.vue";

const router = useRouter();
const baseTable = ref(null as any);
const baseTableSearch = ref(null as any);
const editRef = ref<any>(null);

const route = useRoute()
// 表格搜索初始化searchModel
const baseTableSearchModel = ref({
  columnCount: 4,
  expandLimit: 6,
  autoFit: true,
  columnWidth: '300px',
  labelPosition: 'right',
  labelWidth: '100px',
  search: async (reset: Boolean) => {  //搜索、重置按钮  回调方法钩子   实现父类 ---夸组件调用

    let data = await baseTable.value.getList(baseTableSearch.value.formData, reset)
    // console.info(data); //todo 拿不到数据
    $baseMessage(data.message, 'success', 'vab-hey-message-success');

  },
  items:  [
    {
      "label": "用户昵称",
      "field": "nickName",
      "clearable": true,
      "placeholder": "请输入",
      "type": FormFieldType.INPUT
    },
    {
      "label": "真实姓名",
      "field": "realName",
      "clearable": true,
      "placeholder": "请输入",
      "type": FormFieldType.INPUT
    },
    {
      "label": "手机号码",
      "field": "phone",
      "clearable": true,
      "placeholder": "请输入",
      "type": FormFieldType.INPUT
    },
    {
      "label": "状态",
      "field": "sysIsfreeze",
      "clearable": true,
      "placeholder": "请输入",
      render:()=> {
        return <CommonFrozenStatusSelect/>
      }
    }
  ]
})
// 表格初始化Model
const baseTableModel = ref({
  border: true,
  pagination: true,
  inline: true,
  selectable: true,
  isFullscreen: false,
  minWidth: '200px',
  data: {    //table  初始化
    current: 1,
    size: 10,
    total: 100,
    data: []
  },
  requestData: {api: UserInfoAccountApi.getPageData, query: {}},   //数据源 参数有效性： 'steady|transient'
  columns: [
    {
      "label": "编号",
      "field": "id",
      "width": 200
    },
    {
      "label": "昵称",
      "field": "nickName",
      "width": 250
    },
    {
      "label": "手机号",
      "field": "phone",
      "width": 120
    },
    {
      "label": "当前余额",
      "field": "currentMoney",
      "width": 120
    },
    {
      "label": "当前积分",
      "field": "currentIntegral",
      "width": 120
    },
    {
      "label": "收入佣金",
      "field": "incomeProfit",
      "width": 120
    },
    {
      "label": "支出佣金",
      "field": "expenditureProfit",
      "width": 120
    },
    {
      "label": "当前佣金",
      "field": "currentProfit",
      "width": 120
    },
    {
      "label": "是否是VIP",
      "field": "isVipText",
      "width": 150
    },
    {
      "label": "推荐",
      "field": "recommend",
      "width": 100
    },
    {
      "label": "启用",
      "field": "sysIsfreeze",
      "width": 100
    },
    {
      "label": "是否分佣",
      "field": "isShare",
      "width": 100
    },
    {
      "label": "创建时间",
      "field": "create_time",
      "width": 200
    },
    {
      "label": "更新时间",
      "field": "update_time",
      "width": 200
    }
  ],


  actions: [
    {
      name: "详情",

      buttonClass: 'primary',
      buttonType: 'text',
      click: ({row,handlers}) => {
        router.push({name: 'UserInfoAccountDetail',query: {userId: row.id}})
      },
      isShow: (row: object) => {
        return true;
      },
      fixed: 'right'
    },

  ]

})


onActivated(() => {
})


</script>


